<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>记事本</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>学习vue</title>
    <script src="https://cdn.jsdelivr.net/npm/vue"></script><!--导入官网的vue,就不用去用本地的了-->
    <script src="https://static.runoob.com/code/js/vueapp.js"></script><!--用于model-->
    <script src="/vue.min.js"></script>
    <link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script>
    <script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <script src="/js/bootstrap.js"></script>
    <script src="/js/bootstrap.min.js"></script>
</head>
<style>
    #note{
        margin-left: 500px;
    }
    a:link{
        text-decoration: none;
    }
    .la{
        border: black solid 1px;
        list-style: none;
        width: 174px;
        position: relative;
        left: 0px;
        top: 30px;
    }
	.chart{
		text-align: right;
	  float: right;
	

	}
    .in{
        position: absolute;
    }
</style>
<body>
<div id="note">
   <selection >
       <header>
           <h1>记事本</h1>
           <input class="in" autofocus="autofocus" type="text" v-model="getinput" @keyup.enter="enter" placeholder="请输入">
       </header>
       <selection class="main">
           <ul >
               <li class="la" v-for="(it,index) in list">
                          <div  v-if="show">
                   {{index+1}}:{{it.name}}
                              <button class="chart"  @click="remove(index)">X</button>
                          </div>
               </li>
           </ul>
       </selection>
       <footer style="margin-top:200px"><span @click="clear">clear</span>
       <span>总共有{{list.length}}</span>
       </footer>

   </selection>
</div>
<script>
    var  note=new Vue({
        el:"#note",
        data:{
            getinput:"",
            list:[{name:"花菜"}, {name:"西红柿"}, {name:"土豆"}],
            show:true,
            index:0
        },
        methods:{
            enter:function () {
             alert("输入了"+this.getinput)
                this.list.push({name:this.getinput})/*加入刚输入的数据*/
            },
            remove:function (index) {
               /* this.list.pop()/!*pop()删除的方法*!/*/
                this.list.splice(index,1)/*splice(index,count),删除第几个，后面是数量*/
            },
            clear:function () {
                this.list=[]
                if(  this.list.length!=0){
                    this.show=!this.show/*如果list被清空，就不显示*/
                }
            }
        }

    });
</script>
</body>
</html>